package com.yanqu.road.entity.activity.washe.game;


import com.yanqu.road.entity.activity.washe.config.WasheCardConfig;
import com.yanqu.road.entity.activity.washe.config.WasheConfig;
import com.yanqu.road.entity.activity.washe.config.WasheModeConfig;
import com.yanqu.road.entity.activity.washe.data.WasheUserMatchData;

import java.util.ArrayList;
import java.util.List;

/**
 * 游戏内玩家数据
 */
public class WasheUserGameData {

    private WasheUserMatchData userMatchData;

    // 默认0的
    private long score;
    private long sendExpressionTime;
    private long stepOutTime;
    private boolean ready = true;

    // 游戏开始后才有
    private int step;
    private WasheUserGameCard card = null;
    private List<WasheUserGameSkill> skillList = null;
    private boolean firstOperate = false;                       // 是否先手，目前只用于记录日志

    private boolean robot;                               // 是否小玉接管
    private long robotScore;                             // 巅峰赛小玉接管前分数

    //皮肤相关
    private int boardSkinId = 0;                             // 皮肤id
    private int animationId = 0;                             // 动画id
    private int effectId = 0;                                // 特效id


    // =======================================================

    public static WasheUserGameData createData(WasheConfig config, WasheUserMatchData userMatchData) {
        if (userMatchData == null) {
            return null;
        }

        WasheCardConfig cardConfig = config.getCardConfigMap().get(userMatchData.getCardId());
        List<WasheUserGameSkill> skillList = new ArrayList<>();
        for (Integer skill : userMatchData.getSkills()) {
            skillList.add(new WasheUserGameSkill(skill, config.getSkillUseTimes()));
        }

        WasheUserGameData userGameData = new WasheUserGameData();
        userGameData.setUserMatchData(userMatchData);
        userGameData.setScore(0);
        userGameData.setSendExpressionTime(0);
        userGameData.setCard(new WasheUserGameCard(userMatchData.getCardId(), 0, cardConfig.getCd()));
        userGameData.setSkillList(skillList);
        userGameData.setBoardSkinId(userMatchData.getBoardSkinId());
        userGameData.setAnimationId(userMatchData.getAnimationId());
        userGameData.setEffectId(userMatchData.getEffectId());

        return userGameData;
    }

    public void reduceStep() {
        this.step = this.step - 1;
    }

    public void addStep(int num, WasheModeConfig modeConfig) {
        step = step + num;
        if (step > modeConfig.getMaxStep()) {
            step = modeConfig.getMaxStep();
        }
    }

    public void addScore(long addValue) {
        this.score += addValue;
    }

    // =======================================================

    public WasheUserMatchData getUserMatchData() {
        return userMatchData;
    }

    public void setUserMatchData(WasheUserMatchData userMatchData) {
        this.userMatchData = userMatchData;
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        this.score = score;
    }

    public int getStep() {
        return step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public WasheUserGameCard getCard() {
        return card;
    }

    public void setCard(WasheUserGameCard card) {
        this.card = card;
    }

    public List<WasheUserGameSkill> getSkillList() {
        return skillList;
    }

    public void setSkillList(List<WasheUserGameSkill> skillList) {
        this.skillList = skillList;
    }

    public long getSendExpressionTime() {
        return sendExpressionTime;
    }

    public void setSendExpressionTime(long sendExpressionTime) {
        this.sendExpressionTime = sendExpressionTime;
    }

    public long getStepOutTime() {
        return stepOutTime;
    }

    public void setStepOutTime(long stepOutTime) {
        this.stepOutTime = stepOutTime;
    }

    public boolean isReady() {
        return ready;
    }

    public void setReady(boolean ready) {
        this.ready = ready;
    }

    public boolean isFirstOperate() {
        return firstOperate;
    }

    public void setFirstOperate(boolean firstOperate) {
        this.firstOperate = firstOperate;
    }

    public boolean isRobot() {
        return robot;
    }

    public void setRobot(boolean robot) {
        this.robot = robot;
    }

    public long getRobotScore() {
        return robotScore;
    }

    public void setRobotScore(long robotScore) {
        this.robotScore = robotScore;
    }

    public int getBoardSkinId() {
        return boardSkinId;
    }

    public void setBoardSkinId(int boardSkinId) {
        this.boardSkinId = boardSkinId;
    }

    public int getAnimationId() {
        return animationId;
    }

    public void setAnimationId(int animationId) {
        this.animationId = animationId;
    }

    public int getEffectId() {
        return effectId;
    }

    public void setEffectId(int effectId) {
        this.effectId = effectId;
    }
}
